/**
 * 定义分析仪管理模块
 */
(function(window, angular, undefined){
	var Module = angular.module('water.apps.sw.systemConfig.monitorEquipmentDict.monitorEquipmentDictManager', ['water.entity.commonEntity']);
	
	Module.controller('monitorEquipmentDictManagerController',function($rootScope,$scope,$commonEntityService){

		/**
		 * 新建model
		 */
		$scope.createModel={};
		/**
		 * 编辑model
		 */
		$scope.editModel={};
		/**
		 * 分析仪数据
		 */
		$scope.dataList=[];
		/**
		 * 编辑对话框对象
		 */
		$scope.editDialog;
		/**
		 * 详情对话框对象
		 */
		$scope.detailDialog;
		/**
		 * 新增对话框
		 */
		$scope.createDialog;
		
		/**
		 * 新增按钮点击事件
		 */
		$scope.onCreateClick = function(){
			$scope.createModel = {};
			$scope.createDialog.open();
		}
		/**
		 * 提交事件
		 */
		$scope.onSubmitCreateClick = function(model){
			$commonEntityService.createModel("MONITOR_EQUIPMENT_DICT",model).then(function(){
				$scope.createDialog.close();
				_getList();
				$.messager.alert("保存成功","保存成功",'info');
			});
		}
		
		/**
		 * 取消事件
		 */
		$scope.onCloseCreateClick = function(model){
			$scope.createDialog.close();
		}
		/**
		 * 编辑按钮点击事件
		 */
		$scope.onEditClick = function(key){
			$commonEntityService.getModel("MONITOR_EQUIPMENT_DICT",key).then(function(data){
				$scope.editModel = data;
				$scope.editDialog.open();
			});
		}
		/**
		 * 编辑确认按钮点击事件
		 */
		$scope.onSubmitEditClick = function(model) {
			$commonEntityService.updateModel("MONITOR_EQUIPMENT_DICT",model).then(function() {
				$.messager.alert("保存成功", "保存成功", 'info');
				_getList();
				$scope.editDialog.close();
			});

		}
		/**
		 * 详情按钮点击事件
		 */
		$scope.onDetailClick = function(key) {
			$commonEntityService.getModel("MONITOR_EQUIPMENT_DICT", key).then(
					function(data) {
						$scope.detailModel = data;
						$scope.detailDialog.open();
					});
		}
		/**
		 * 删除按钮点击事件
		 */
		$scope.onDeleteClick = function(key) {
			$.messager.confirm("确认", "确定要删除这条记录吗？", function(r) {
				if (r) {
					$commonEntityService.deleteModel("MONITOR_EQUIPMENT_DICT", key)
							.then(function() {
								$.messager.alert("删除成功", "删除成功", 'info');
								_getList();
							});
				}
			});
		}
		/**
		 * 刷新列表
		 */
		$scope.onRefreshClick = function(){
			_getList();
		}
		
		
		/**
		 * 获取列表
		 */
		function _getList(){
			$commonEntityService.getList("MONITOR_EQUIPMENT_DICT",{}).then(function(data){
				$scope.dataList = data.data;
			});
		};
		
		_getList();
	});
}(window, angular));	